//
//  User.m
//  deerkids
//
//  Created by 王昭的Mac Air on 2017/8/28.
//  Copyright © 2017年 wangzhao. All rights reserved.
//

#import "User.h"

@implementation User

//8248ee5186e944aeaf69aa14046cb44a6e7e36fe

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super init];
    if (self) {
        self = [User yy_modelWithDictionary:dictionary];
    
        
//        if(!is_null(dictionary[@"vip"]) && [dictionary[@"vid"] isKindOfClass:[NSDictionary class]]){
//            self.vip = convertToString(dictionary[@"vip"][@"name"]);
//        }
//
//        self.country_name = trimString(country_name);
    }
    return self;
}


+ (NSDictionary<NSString *,id> *)modelCustomPropertyMapper
{
    return @{
             @"user_id" : @"user_id",
             @"user_name" : @"user_name",
             @"user_gender" : @"user_gender",
             @"user_avatar" : @"user_avatar",
             @"group_name" : @"group_name",
             @"group_icon" : @"group_icon",
             @"group_now_grade" : @"group_now_grade",
             @"group_next_grade" : @"group_next_grade",
             @"user_sign" : @"user_sign",
             @"user_gold" : @"user_gold",
             @"birth_year" : @"birth_year",
             @"birth_month" : @"birth_month",
             @"birth_day" : @"birth_day",
             @"wallpaper_url":@"wallpaper_url",
             @"email":@"email",
             @"user_qq":@"user_qq",
             @"user_credit":@"user_credit",
             @"user_diamond":@"user_diamond",
             @"count_follow":@"count_follow",
             @"count_view":@"count_view",
             @"now_value":@"now_value",
             @"count_like":@"count_like",
             @"count_fans":@"count_fans",
             @"count_fav":@"count_fav",
             @"publish_total":@"publish_total",
             @"user_blood":@"user_blood",
             @"user_height":@"user_height",
             @"user_weight":@"user_weight",
             @"user_emotion":@"user_emotion",
             @"user_region":@"user_region",
             @"user_constellation":@"user_constellation",
             @"user_taglist":@"user_taglist",
             @"user_like":@"user_like",
             @"user_is_like":@"user_is_like",
             @"count_wall":@"count_wall",
             @"count_visit":@"count_visit",
             @"user_relation":@"user_relation",
             @"is_vip":@"is_vip"
             };
}


//归档：说明对象哪些属性写入沙盒
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.user_id forKey:@"user_id"];
    [aCoder encodeObject:self.user_name forKey:@"user_name"];
    [aCoder encodeInteger:self.user_gender forKey:@"user_gender"];
    [aCoder encodeObject:self.user_avatar forKey:@"user_avatar"];
    [aCoder encodeObject:self.group_name forKey:@"group_name"];
    [aCoder encodeObject:self.group_icon forKey:@"group_icon"];
    [aCoder encodeInteger:self.group_now_grade forKey:@"group_now_grade"];
    
    [aCoder encodeInteger:self.group_next_grade forKey:@"group_next_grade"];
    [aCoder encodeObject:self.user_sign forKey:@"user_sign"];
    [aCoder encodeObject:self.user_gold forKey:@"user_gold"];
    [aCoder encodeObject:self.birth_year forKey:@"birth_year"];
    [aCoder encodeObject:self.birth_month forKey:@"birth_month"];
    [aCoder encodeObject:self.birth_day forKey:@"birth_day"];
    [aCoder encodeObject:self.wallpaper_url forKey:@"wallpaper_url"];
    [aCoder encodeBool:self.isOnline forKey:@"isOnline"];
    [aCoder encodeObject:convertToString(self.is_vip) forKey:@"is_vip"];
    
}

//反归档：说明对象的哪些属性从沙盒里取出来
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super init]) {
        self.user_id = [aDecoder decodeObjectForKey:@"user_id"];
        self.user_name = [aDecoder decodeObjectForKey:@"user_name"];
        self.user_gender = [aDecoder decodeIntegerForKey:@"user_gender"];
        self.user_avatar = [aDecoder decodeObjectForKey:@"user_avatar"];
        self.group_name = [aDecoder decodeObjectForKey:@"group_name"];
        self.group_icon = [aDecoder decodeObjectForKey:@"group_icon"];
        self.group_now_grade = [aDecoder decodeIntegerForKey:@"group_now_grade"];
        
        self.group_next_grade = [aDecoder decodeIntegerForKey:@"group_next_grade"];
        self.user_sign = [aDecoder decodeObjectForKey:@"user_sign"];
        self.user_gold = [aDecoder decodeObjectForKey:@"user_gold"];
        self.birth_year = [aDecoder decodeObjectForKey:@"birth_year"];
        self.birth_month = [aDecoder decodeObjectForKey:@"birth_month"];
        
        self.birth_day = [aDecoder decodeObjectForKey:@"birth_day"];
        self.wallpaper_url = [aDecoder decodeObjectForKey:@"wallpaper_url"];
        
        self.isOnline = [aDecoder decodeBoolForKey:@"isOnline"];
        self.is_vip = [aDecoder decodeObjectForKey:@"is_vip"];
        
    }
    return self;
}

@end
